home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2001 May / SGI IRIX Base Documentation 2001 May.iso / usr / share / catman / u_man / cat3 / Tm / tclmotif.z / tclmotif
Encoding:
Text File  |  1998-10-30  |  72.5 KB  |  1,717 lines

  1.  
  2.  
  3.  
  4. ttttccccllllMMMMoooottttiiiiffff((((3333TTTTmmmm))))                                                    ttttccccllllMMMMoooottttiiiiffff((((3333TTTTmmmm))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      ttttccccllllMMMMoooottttiiiiffff - the binding of tcl to the Motif widget set.
  10.  
  11.  
  12. IIIInnnnttttrrrroooodddduuuuccccttttiiiioooonnnn
  13.      This is a binding of the Tcl language to the Motif widgets.  Tcl is an
  14.      interpreted language originally intended for use as a command language
  15.      for other applications. It has been used for that, but has also become
  16.      useful as a language in its own right.
  17.  
  18.      Tcl has been extended by a set of widgets called Tk. The Tk widgets are
  19.      not based on the Xt Intrinsics, but are built above Xlib. They allow an
  20.      easy way of writing X Window applications.
  21.  
  22.      The standard set of widgets in the X world is now the Motif set. This
  23.      forms a large set of widgets, and these have been through a large amount
  24.      of development over the last five years. Use of this set is sometimes a
  25.      requirement by busineses, and other widget sets try to conform to them in
  26.      appearance and behaviour.
  27.  
  28.      This system allows the programmer to use the Motif widgets instead of the
  29.      Tk widgets from Tcl programs. This increases programmer choices, and
  30.      allows comparison of the features of both Tcl and the Tk/Motif style of
  31.      widget programming.  The binding gives the full set of Motif widgets,
  32.      accessible through the simple interpreted Tcl language.
  33.  
  34.  
  35. AAAAcccckkkknnnnoooowwwwlllleeeeddddggggmmmmeeeennnnttttssss
  36.      This system is based on Tk for the style of widget programming. This was
  37.      because it provides a good model, but it also allows the Tcl programmer
  38.      to move relatively easily between Tk and Motif programming. An
  39.      alternative style of binding to Motif is used in the WKSH system, which
  40.      performs a similar sort of role for the Korn Shell. The WKSH is much
  41.      closer to the C API for Xt than is Tk. An intermediate style is provided
  42.      by the Wafe binding of Xt-based widgets to tcl.
  43.  
  44.      The documentation is incomplete (and is likely to be for a very long
  45.      time). Consequently the programmer will probably need to refer to the
  46.      Motif Programers Reference Manual. The system has been designed so that
  47.      it is relatively easy to translate the C-based information in this manual
  48.      into the corresponding Tcl information. This has been aided by the
  49.      consistency with which Motif has been implemented in certain areas.
  50.  
  51.  
  52. RRRRuuuunnnnnnnniiiinnnngggg TTTTccccllll////MMMMoooottttiiiiffff pppprrrrooooggggrrrraaaammmmssss
  53.      Tcl/Motif programs may be run by the `moat' (MOtif And Tcl) interpreter.
  54.      When called with no arguments it reads Tcl commands from standard input.
  55.      When called by
  56.  
  57.           moat file-name
  58.  
  59.      it reads Tcl commands from `file-name' and executes them.   This  is  the
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. ttttccccllllMMMMoooottttiiiiffff((((3333TTTTmmmm))))                                                    ttttccccllllMMMMoooottttiiiiffff((((3333TTTTmmmm))))
  71.  
  72.  
  73.  
  74.      same as any other extension to ``tclsh''.
  75.  
  76.      The standard Xt command line options may appear after the  file-name,  as
  77.      in
  78.  
  79.           moat file-name -width 200 -height 100
  80.  
  81.      Depending on your shell interpreter, you will probably  be  able  to  run
  82.      Tcl/Motif  programs  as  standalone programs. If your moat interpreter is
  83.      installed in say `/usr/local/bin/moat', make this the first line of  your
  84.      executable program:
  85.  
  86.           #!/usr/local/bin/moat
  87.  
  88.  
  89. TTTThhhheeee MMMMoooottttiiiiffff wwwwoooorrrrlllldddd
  90.      In earlier versions than 0.8, a specialised interpreter was used, much
  91.      like Tk's ``wish''. To conform to the new extension methods of tcl7.0,
  92.      this was changed. Part of the result of this is that the Xt world has to
  93.      be explicitly brought into existence. This also allows the class and
  94.      fallback resources to be set, and leaves hooks for things like setting
  95.      the application icon to be added later to this binding.
  96.  
  97.      The three world manipulation functions added are
  98.  
  99.           xtAppInitialize
  100.           . realizeWidget
  101.           . mainLoop
  102.  
  103.      xtAppInitialize may take parameters of -class, -fallback_resources and
  104.      -options. If the class option is omitted, the binding will deduce a class
  105.      by capitalising the first letter of the application name, and - if it was
  106.      an `x' - also capitalising the second letter.  The -fallback_resources
  107.      may be used to set resources in case there is no application defaults
  108.      file or user file setting them. The -options may be used to set
  109.      additional application resources for later retrieval by the root widget
  110.      method getAppResources.
  111.  
  112.      A typical tclMotif program has the structure
  113.  
  114.           # tcl function definitions
  115.           # ...
  116.  
  117.           xtAppInitialize -class MyClass
  118.  
  119.           # widget creation commands
  120.           # ...
  121.  
  122.           . realizeWidget
  123.           . mainLoop
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. ttttccccllllMMMMoooottttiiiiffff((((3333TTTTmmmm))))                                                    ttttccccllllMMMMoooottttiiiiffff((((3333TTTTmmmm))))
  137.  
  138.  
  139.  
  140. WWWWiiiiddddggggeeeetttt nnnnaaaammmmiiiinnnngggg
  141.      Widgets are visual objects that exist on the screen.  They are organised
  142.      as a hierarchy, with the application itself forming the root of this
  143.      hierarchy.  The naming of objects within this hierarchy is similar to the
  144.      ``absolute path names'' of Unix files with a `.' replacing the `/' of
  145.      Unix.  The application itself is known as `.'.  A Form in the application
  146.      may be known as `.form1'.  A Label in this form may be `.form1.okLabel',
  147.      and so on.  Note that Xt requires that `.' can only have one child
  148.      (except for dialogs).  This naming convention is the same as in Tk.
  149.  
  150.  
  151. WWWWiiiiddddggggeeeetttt ccccrrrreeeeaaaattttiiiioooonnnn
  152.      Widgets belong to classes, such as Label, PushButton or List.  For each
  153.      class there is a creation command which takes the pathName of the object
  154.      as first argument with optional further arguments:
  155.  
  156.           xmForm .form1
  157.           xmLabel .form1.okLabel
  158.           xmLabel .form1.cancelLabel \
  159.                -labelString "Get rid of me"
  160.  
  161.      creates a Form `form1' as child of `.',  and  two  Labels  `okLabel'  and
  162.      `cancelLabel'  as  children  of `form1'. The `cancelLabel' has additional
  163.      arguments that set the labelString to "Get rid  of  me".  Note  that  the
  164.      continuation  character  `\'  may  be  used to spread a line over several
  165.      lines.
  166.  
  167.      The set of classes generally mirrors the  Motif  set.   Some  widgets  in
  168.      Motif  and  Xt  are  not  accessible  from  this binding because they are
  169.      intended for use in inheritance only, such as Core  and  Primitive.   The
  170.      types  of  widgets  that  can be created using this include the primitive
  171.      widgets:
  172.  
  173.           xmArrowButton - a simple arrow,
  174.           xmDrawnButton - a button with graphics in it
  175.           xmCascadeButton - for use in menus
  176.           xmToggleButton - for on/off boxes
  177.           xmLabel - a fixed piece of text
  178.           xmText - a text editor
  179.           xmTextField - a one line text editor
  180.           xmSeparator - for simple lines between objects
  181.           xmList - a list selector
  182.           xmScrollBar - a horizontal or vertical scrolling bar
  183.  
  184.      and the Manager widgets:
  185.  
  186.           xmBulletinBoard - simple geometry management
  187.           xmRowColumn - regular geometry management
  188.           xmPanedWindow - multiple panes separated by sashes
  189.           xmFrame - a 3-D border
  190.           xmScale - a slider on a scale
  191.           xmScrolledWindow - for displaying a clip view over an area
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. ttttccccllllMMMMoooottttiiiiffff((((3333TTTTmmmm))))                                                    ttttccccllllMMMMoooottttiiiiffff((((3333TTTTmmmm))))
  203.  
  204.  
  205.  
  206.           xmMainWindow - contains a menu bar and the main application windows
  207.           xmForm - for irregular geometry arrangements
  208.           xmMessageBox - message display area
  209.           xmCommand - a command entry area with a history list
  210.           xmFileSelectionBox - selection of a file from a list
  211.  
  212.      Motif has  two  special  commands  for  creating  a  ScrolledList  and  a
  213.      ScrolledText.   These  commands actually create a pair of widgets: a List
  214.      or Text inside a ScrolledWindow. To create such widgets is similar to the
  215.      C  binding:  the  List  (or  Text)  widget  name  is given. If the parent
  216.      ScrolledWindow is required then you have to call the ``parent'' method on
  217.      the List or Text widget.
  218.  
  219.           xmForm .form1
  220.           xmScrolledList .form1.list2
  221.           [.form1.list2 parent] setValues -attachTop attach_form
  222.  
  223.      Motif also has convenience functions that create  dialogs.   These  don't
  224.      create  ordinary  widgets,  but  Motif  pretends  that they do.  TclMotif
  225.      follows this, and allows you to use commands such as
  226.  
  227.           xmQuestionDialog .askMe
  228.  
  229.      to create such dialogs. When you have to destroy  such  widgets,  destroy
  230.      the parent:
  231.  
  232.           [.askMe parent] destroy
  233.  
  234.      This set of dialogs includes:
  235.  
  236.  
  237.           xmBulletinBoardDialog - a dialog with arbitrary contents,  based  on
  238.                bulletinBoard
  239.  
  240.           xmFileSelectionDialog - a dialog based on fileSelectionBox
  241.  
  242.           xmFormDialog - a dialog based on form
  243.  
  244.           xmInformationDialog - a dialog displaying information
  245.  
  246.           xmMessageDialog - a dialog showing a message
  247.  
  248.           xmPromptDialog - a dialog with a prompt area
  249.  
  250.           xmQuestionDialog - a dialog asking a question
  251.  
  252.           xmSelectionBoxDialog - a dialog based on selectionBox
  253.  
  254.           xmWarningDialog - a dialog showing a warning message
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.                                                                         PPPPaaaaggggeeee 4444
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268. ttttccccllllMMMMoooottttiiiiffff((((3333TTTTmmmm))))                                                    ttttccccllllMMMMoooottttiiiiffff((((3333TTTTmmmm))))
  269.  
  270.  
  271.  
  272.           xmWorkingDialog - a dialog showing a busy working message
  273.  
  274.      For example, consider a rowColumn containing two labels and a pushButton,
  275.      where the rowColumn is inside a mainWindow:
  276.  
  277.           xmMainWindow .main
  278.           xmRowColumn .main.rowcol
  279.           xmLabel .main.rowcol.label1
  280.           xmLabel .main.rowcol.label2
  281.           xmPushButton .main.rowcol.btn
  282.  
  283.      Not all objects used in the OSF C library are supported: gadgets are  not
  284.      supported  by TclMotif, nor are the ``simple'' menu functions.  These are
  285.      design  decisions:  I  don't  like  gadgets  because  they  place   extra
  286.      processing code and complexity on the client-side Motif library, the need
  287.      for which has been largely removed by improvements in X servers; I  don't
  288.      like  the  simple  menu  functions  very much either because they are yet
  289.      another attempt to fix up a  complex  system  to  which  lots  of  people
  290.      already  have  their  own  solutions,  and it is not clear that this is a
  291.      ``better'' one. I doubt  if  reversal  of  these  would  cause  too  many
  292.      problems, but I don't feel like investigating them yet.
  293.  
  294.  
  295.  
  296. MMMMaaaannnnaaaaggggiiiinnnngggg wwwwiiiiddddggggeeeettttssss
  297.      Before a widget can be displayed, it must be brought under the geometry
  298.      control of its parent (similar to placing a Tk widget). This can be done
  299.      by the ``manageChild'' method of each widget, but also by an optional
  300.      third command to each widget creation function, similar to the
  301.      XtCreateManagedWidget functions. For example,
  302.  
  303.           xmLabel .l1 managed
  304.           xmLabel .l2
  305.           .l2 manageChild
  306.  
  307.  
  308. DDDDooooccccuuuummmmeeeennnnttttaaaattttiiiioooonnnn
  309.      The widgets described above not only look and act the same as the Motif
  310.      widgets, they _a_r_e the Motif widgets. So descriptions of them in any Motif
  311.      book or reference apply. In the Motif Programmers Reference these widgets
  312.      are described under the same names, with the initial `x' capitalised as
  313.      in XmPushButton.  The creation functions are prefixed by ``XmCreate'' as
  314.      in XmCreatePushButton.
  315.  
  316.      The TclMotif documentation is at present incomplete. There should be a
  317.      man page for each widget, under the name of the widget prefixed by ``Tm''
  318.      as in TmPushButton.
  319.  
  320.      In addition, there are additional manual pages. The entry for ``moat''
  321.      describes the interpreter that will generally be used for TclMotif.  The
  322.      entry for TmRoot describes the commands available for the root widget
  323.      ``.''. Such commands usually apply to the Xt application context.
  324.  
  325.  
  326.  
  327.                                                                         PPPPaaaaggggeeee 5555
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334. ttttccccllllMMMMoooottttiiiiffff((((3333TTTTmmmm))))                                                    ttttccccllllMMMMoooottttiiiiffff((((3333TTTTmmmm))))
  335.  
  336.  
  337.  
  338. WWWWiiiiddddggggeeeetttt ccccoooommmmmmmmaaaannnnddddssss
  339.      Creating a widget actually creates a Tcl command known by its pathName.
  340.      This command may be executed with at least one parameter to either change
  341.      the behavior of the object or the value of its components, or to get
  342.      information about the object.  The parameter acts like a ``method'' to
  343.      the object, and specifies an action that it should perform. The
  344.      parameters that are recognised by every object include:
  345.  
  346.  
  347.           unmanageChild - remove the object from its parents geometry
  348.                management, which makes it disappear from the display
  349.  
  350.           manageChild - bring it back under geometry management and make it
  351.                appear again
  352.  
  353.           mapWidget - remain under geometry management, but make it disappear
  354.  
  355.           unmapWidget - make it reappear
  356.  
  357.           realizeWidget - create windows for the widget and its children
  358.                (usually used only by ``.'')
  359.  
  360.           getValues - obtain properties of the widget
  361.  
  362.           setValues - set properties of the widget
  363.  
  364.           parent - return the parent of the widget
  365.  
  366.           destroyWidget - destroy the widget and all its children
  367.  
  368.           setSensitive - change the sensitivity of the widget to responses to
  369.                input
  370.  
  371.           callActionProc - call an action procedure (usually used in
  372.                regression testing)
  373.  
  374.           dragStart - used in drag and drop
  375.  
  376.           dropSiteRegister - used in drag and drop
  377.  
  378.           getGC - return a graphics context (used for drawing in DrawingArea
  379.                and DrawnButton)
  380.  
  381.           resources - return a list of all resources. Each resource is a list
  382.                of the resource name as used in setValues/getValues, the
  383.                resource name as known internally to Motif, the resource class,
  384.                the resource type as known to Motif and the value of the
  385.                resource. In cases where this value does not make sense (eg a
  386.                bitmap), a null string is returned.
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.                                                                         PPPPaaaaggggeeee 6666
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400. ttttccccllllMMMMoooottttiiiiffff((((3333TTTTmmmm))))                                                    ttttccccllllMMMMoooottttiiiiffff((((3333TTTTmmmm))))
  401.  
  402.  
  403.  
  404.           any string ending in ``Callback'' - register Tcl code to be executed
  405.                when something happens to the widget.
  406.  
  407.      For example,
  408.  
  409.           .form1.okLabel unmanageChild
  410.  
  411.           .form1.okButton activateCallback \
  412.                {puts stdout "I was pushed into it..."}
  413.  
  414.      Unmanaging a widget removes it from the display, and  from  the  geometry
  415.      management  of  its  parent. Managing it reverses this. The other methods
  416.      are explained later.
  417.  
  418.  
  419. OOOOtttthhhheeeerrrr wwwwiiiiddddggggeeeetttt ccccoooommmmmmmmaaaannnnddddssss
  420.      The root widget ``.'' has a number of commands unique to it. Generally,
  421.      these are commands that use the application context (moat only uses one
  422.      application context). These commands include
  423.  
  424.           addInput
  425.           removeInput
  426.           mainLoop
  427.  
  428.      Both Text and List have a large number of other commands due to the
  429.      complexity of these widgets. Other widgets also have special methods.
  430.      See the manual pages for further information.
  431.  
  432.  
  433. WWWWiiiiddddggggeeeetttt rrrreeeessssoooouuuurrrrcccceeeessss
  434.      Each widget has a set of resources that can be set at creation time, set
  435.      at a later time, or queried for their value. For example, an xmPushButton
  436.      has a width and a height, a labelString that is the text that will show
  437.      in it, a foreground and background colour, a fontList giving the set of
  438.      fonts that will be used to draw the text, and so on.
  439.  
  440.      All resource names are prefixed by a minus `-' in Tcl programs, for
  441.      consistency with the Tk widgets. On setting a value, all resources take
  442.      the next word as value, and on getting a value the next word is the name
  443.      of a variable to  store the value in.
  444.  
  445.      On creation, the resource/value pairs come after the widget pathName, as
  446.      in
  447.  
  448.           xmLabel .okLabel -labelType pixmap -labelPixmap xlogo32
  449.  
  450.      which sets the labelType to pixmap and the labelPixmap to xlogo32.
  451.  
  452.      Resources can be set at any time using the setValues method
  453.  
  454.           .text setValues -editMode editable -value "Some text"
  455.  
  456.  
  457.  
  458.  
  459.                                                                         PPPPaaaaggggeeee 7777
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466. ttttccccllllMMMMoooottttiiiiffff((((3333TTTTmmmm))))                                                    ttttccccllllMMMMoooottttiiiiffff((((3333TTTTmmmm))))
  467.  
  468.  
  469.  
  470.      which ensures that the text widget can be edited, and  sets  a  value  of
  471.      "Some text".
  472.  
  473.      Resources can be obtained from the widget  using  the  getValues  method.
  474.      For example
  475.  
  476.           .fileSelectionBox getValues \
  477.               -dirSpec file_selected \
  478.               -directory dir
  479.  
  480.      stores in the Tcl variable file_selected the filename that  was  entered,
  481.      and  in  the  Tcl  variable dir the directory in which the file selection
  482.      occurred.
  483.  
  484.      Each widget inherits resources from superclasses. For example, Label is a
  485.      subclass  of Primitive which in turn is a subclass of Core.  From Core it
  486.      inherits resources such as background, height and width.  From  Primitive
  487.      it  inherits  resources  such as foreground.  It is neccessary to look at
  488.      these superclasses.  In addition, each class adds extra  resources.   For
  489.      example,  Label  has  the additional resources labelType, labelPixmap and
  490.      labelString, among others.
  491.  
  492.      Resources are documented in  the  Tm  man  page  for  each  widget.  This
  493.      documentation is weak.
  494.  
  495.      Resource names can be obtained from  the  Motif  documentation  for  each
  496.      widget.  The  Motif  documentation  for  each  widget has a set of tables
  497.      headed ``Resource Set''.  In the table of resources, the names  of  these
  498.      are  given  prefixed by ``XmN'', such as XmNeditMode.  Drop the prefix to
  499.      get the Tcl resource name. Case is important here.
  500.  
  501.      Resource values can also be obtained from the Motif  documentation.   For
  502.      each resource look at its type.  Types such as Dimension and Position are
  503.      numeric types, and along with int types need an integer  value.   In  the
  504.      Tcl  program  they  are implemented as Tcl strings, as is everything.  In
  505.      fact, all resource values are Tcl strings.  Pixmaps, for example, are the
  506.      string  name  of  a pixmap such as ``xlogo32''.  Pixel is a color such as
  507.      ``blue'', or a hexadecimal representation of the color.   Types  such  as
  508.      the  arrowDirection  of  an  ArrowButton  form a discrete set with values
  509.      listed as XmARROW_UP, XmARROW_DOWN,  etc.   For  these  types,  drop  the
  510.      ``Xm''  and  use the rest of the string as the value.  On setting values,
  511.      case is not important but on getting values the string will be lower case
  512.      for these discrete types.
  513.  
  514.      So for example, a pushButton may have
  515.  
  516.           xmPushButton .btn -width 100
  517.           .btn setValues -labelString "Push Me" -foreground red
  518.           .btn getValues -background bg
  519.           puts stdout "background colour is $bg"
  520.  
  521.  
  522.  
  523.  
  524.  
  525.                                                                         PPPPaaaaggggeeee 8888
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532. ttttccccllllMMMMoooottttiiiiffff((((3333TTTTmmmm))))                                                    ttttccccllllMMMMoooottttiiiiffff((((3333TTTTmmmm))))
  533.  
  534.  
  535.  
  536. CCCCaaaallllllllbbbbaaaacccckkkkssss
  537.      When the user does things to a widget, it may cause the widget to take
  538.      certain actions.  For example, when a button is pressed it changes
  539.      appearance to look pressed in. Some of these actions can have Tcl code
  540.      attached to them, so that the Tcl code is evaluated when the action is
  541.      performed. The Tcl code is attached to a ``callback'' by a widget
  542.      command.  For example, a pushButton has an activateCallback that is
  543.      called when the user presses and releases the left mouse button inside
  544.      the widget; it has an armCallback that is called when the user presses
  545.      the mouse button; it has a disarmCallback that is called when the user
  546.      releases the mouse button inside the widget.
  547.  
  548.      Tcl code is attached to a callback by giving it as the second argument to
  549.      the appropriate widget methodod. For example,
  550.  
  551.           .btn armCallback {puts stdout "Stop squashing me!!!"}
  552.           .btn disarmCallback {puts stdout "That's better!"}
  553.  
  554.      There are two ways of specifying the Tcl code: as above, giving  all  the
  555.      code  as  a  single word (including a list or a string), or as individual
  556.      words:
  557.  
  558.           .btn armCallback puts stdout "Stop squashing me!!!"
  559.  
  560.      The names of the callbacks available for a particular widget are  derived
  561.      from the resource documentation for the Motif widget.  Each callback ends
  562.      with the string "Callback" in its name.  Drop the "XmN"  from  the  Motif
  563.      description   to   gain   the  widget  command.   Callbacks  are  treated
  564.      differently to  other  resources  because  the  Xt  toolkit  treats  them
  565.      differently  -  the  resource  is not meant to be handled directly by any
  566.      ordinary application.
  567.  
  568.  
  569. CCCCaaaallllllllbbbbaaaacccckkkk ssssuuuubbbbssssttttiiiittttuuuuttttiiiioooonnnnssss
  570.      Motif supplies information to each callback function that is specific to
  571.      the widget type.  Generally this is not of much interest. However, for
  572.      some widgets such as List this is used to supply important information,
  573.      such as what item in the List was selected! To make this available to the
  574.      Tcl callback function a pattern substitution mechanism may be used.  Any
  575.      ``%'' followed by a word will be treated as a pattern for potential
  576.      substitution.  For example, ``%item'' in a List will be replaced by the
  577.      item selected, and ``%item_position'' will be replaced by its position in
  578.      the list.  An example list callback is
  579.  
  580.           .list singleSelectionCallback \
  581.                {print_info %item %item_position}
  582.  
  583.           proc print_info {item position} {
  584.               puts stdout "item was $item, at position $position"
  585.           }
  586.  
  587.      The substitutions allowed may be found from the Motif documentation.   In
  588.  
  589.  
  590.  
  591.                                                                         PPPPaaaaggggeeee 9999
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598. ttttccccllllMMMMoooottttiiiiffff((((3333TTTTmmmm))))                                                    ttttccccllllMMMMoooottttiiiiffff((((3333TTTTmmmm))))
  599.  
  600.  
  601.  
  602.      the  description  of  callback information one or more structures will be
  603.      defined. The field names in these structures are the names used in  ``%''
  604.      substitutions.  Not all of the possibilities are implemented yet. This is
  605.      admittedly obscure and not easy to find, so  the  TclMotif  documentation
  606.      needs to fix this lack. If you feel upto reading C code instead, the upto
  607.      date ``list'' is found in the file ``tmExpand.c''
  608.  
  609.      Every callback supports a substitution  of   ``%call_data''.  This  is  a
  610.      keyed list of all valid values in the callback structure. It is a list of
  611.      two-element lists, where each two-element list consists of  the  name  of
  612.      the field followed by its value. For example, for an arrowButton it could
  613.      be
  614.           {
  615.               {reason activate}
  616.               {event event-12345}
  617.               {click_count 1}
  618.           }
  619.      (the event value is a pointer to the Xlib data  structure  which  may  be
  620.      used by tclMotif, but is not expected to be examined by a tcl program.)
  621.  
  622.      Some callback information is actually contained in the event that  caused
  623.      the  callback  to  occur. The event may be obtained from the substitution
  624.      %event. A tcl command ``xEvent'' may then be used to access the fields of
  625.      the  event.  This  command  takes  the  event  and  an  argument which is
  626.      identical to the Tk %  substitutions.  For  example,  to  extract  the  x
  627.      coordinate from a motion event while in the callback, one could have
  628.           $w setValues \
  629.             -translations "<Motion>: action(trackit %event)"
  630.  
  631.           proc trackit {event} {
  632.             set x [xEvent $event x]
  633.             puts stdout $x
  634.           }
  635.  
  636.  
  637. TTTTeeeexxxxtttt vvvveeeerrrriiiiffffyyyy ccccaaaallllllllbbbbaaaacccckkkkssss
  638.      The Text widget allows special processing by the application of text
  639.      entered.  After a character has been typed, or text pasted in, initial
  640.      processing by the Text widget determines what the user is entering. This
  641.      text is then passed to special callback functions. These functions can
  642.      make copies of the text, can alter it, or can set a flag to say do not
  643.      display it. Simple uses for this are a password entry widget that reads
  644.      the text but does not display it (or echoes `*' instead), or text
  645.      formatting widgets.
  646.  
  647.      The callback mechanism for this is basically the same as for  other
  648.      callbacks, and similar sorts of substitutions are allowed. For example,
  649.      the term %currInsert is replaced by the current insertion position. Other
  650.      substitutions do not give a value, but rather give the name of a tcl
  651.      variable. This allows the application to change the value as required.
  652.      The tcl variable is in the context of the callback caller, so upvar
  653.      should be used. For example, to turn off echoing of characters, the
  654.  
  655.  
  656.  
  657.                                                                        PPPPaaaaggggeeee 11110000
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664. ttttccccllllMMMMoooottttiiiiffff((((3333TTTTmmmm))))                                                    ttttccccllllMMMMoooottttiiiiffff((((3333TTTTmmmm))))
  665.  
  666.  
  667.  
  668.      following should be done:
  669.  
  670.           .text modifyVerifyCallback {no_echo %doit}
  671.  
  672.           proc no_echo {doit} {
  673.             upvar 1 $doit do_insert
  674.  
  675.             set do_insert false
  676.           }
  677.  
  678.      (Actually,   the   tcl   variable   here   is   the    global    variable
  679.      ``_Tm_Text_Doit''. For this reason, variables beginning with ``_Tm_'' are
  680.      reserved for use by the TclMotif library.)
  681.  
  682.      Other substitutions that can be made in  the  modifyVerify  callback  are
  683.      ``ptr''  and ``length''. ``ptr'' is the string that is being entered, and
  684.      ``length'' is its length. These may be changed by the callback procedure.
  685.      For example, to change all incoming text to uppercase,
  686.  
  687.           proc allcaps {ptr length} {
  688.               upvar 1 $ptr p
  689.               upvar 1 $length l
  690.  
  691.               if {$l == 0} return
  692.               set upper [string toupper $p]
  693.               set p $upper
  694.           }
  695.  
  696.           .text modifyVerifyCallback {allcaps %ptr %length}
  697.  
  698.  
  699. DDDDiiiiaaaallllooooggggssss
  700.      Selection Box has a number of component children, which may be managed or
  701.      unmanaged by the application. If the SelectionBox was named .sel, these
  702.      are
  703.  
  704.           .sel.Items
  705.           .sel.ItemsList
  706.           .sel.Selection
  707.           .sel.Text
  708.           .sel.Separator
  709.           .sel.Apply
  710.           .sel.Cancel
  711.           .sel.Help
  712.           .sel.OK
  713.  
  714.      The same applies to Message Box.  These  widgets  are  often  managed  or
  715.      unmanaged to add or remove elements from a dialog. Each of these children
  716.      is created with a method  handler  appropriate  to  the  type  of  child.
  717.      However,  Motif  documentation  states that no assumptions should be made
  718.      about this type, so you should check the  type  before  using  a  widget-
  719.      specific  method.   For  example,  the  ItemsList  in  a  SelectionBox is
  720.  
  721.  
  722.  
  723.                                                                        PPPPaaaaggggeeee 11111111
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730. ttttccccllllMMMMoooottttiiiiffff((((3333TTTTmmmm))))                                                    ttttccccllllMMMMoooottttiiiiffff((((3333TTTTmmmm))))
  731.  
  732.  
  733.  
  734.      currently a Motif List.  To set the selectedPosition, one can use a  List
  735.      method:
  736.           xmSelectionBox .selBox managed
  737.           selBox.ItemsList setValues \
  738.               -items {a b c d} \
  739.               -itemCount 4
  740.  
  741.           if {[.selBox.ItemsList class] == "XmList"} {
  742.               .selBox.ItemsList selectPosition 4 false
  743.           }
  744.  
  745.      Whatever the type, the set of methods of the  tclMotif  Core  widget  are
  746.      supported.    In    particular,    the    methods   ``manageChild''   and
  747.      ``unmanageChild'' are available.
  748.  
  749.  
  750. AAAAccccttttiiiioooonnnnssss
  751.      Actions may be added to a widget in a similar way to the C version. In
  752.      that you define an action in a translation table which is set in the
  753.      widget. You then have to register the action with the toolkit so that it
  754.      is attached to a C function. In this binding, the tcl code is placed as
  755.      the arguments to the action in the translation table. Registering the
  756.      action links a generic action handler which in turn will handle the tcl
  757.      code. Here is what it looks like to add an action to make an arrow turn
  758.      left or right when `l' or `r' is pressed:
  759.  
  760.           xmArrowButton .arrow managed
  761.  
  762.           .arrow setValues -translations \
  763.                "<Key>r: action(arrow_direction %w arrow_right) \n\
  764.                    <Key>l: action(\"arrow_direction %w arrow_left\")"
  765.  
  766.           proc arrow_direction {arrow direction} {
  767.             puts stdout "Changing direction to $direction"
  768.             $arrow setValues -arrowDirection $direction
  769.           }
  770.  
  771.      The pattern ``%w'' is substituted for the name of the  tcl  widget.  More
  772.      substitutions may be added in later (eg for x, y).
  773.  
  774.  
  775.  
  776.  
  777. EEEExxxxaaaammmmpppplllleeeessss
  778.      A number of examples are in the programs directory. Those with `DH' in
  779.      them duplicate the examples in Dan Heller's ``Motif Programming Manual'',
  780.      O'Reilly & Associates Inc. Those that are just numbered are undocumented
  781.      test programs. They may not behave in a nice way, but that doesn't matter
  782.      too much.
  783.  
  784.      The following example is in the programs directory as progEG.  The
  785.      typical structure of a Motif program is that the top-level object is a
  786.  
  787.  
  788.  
  789.                                                                        PPPPaaaaggggeeee 11112222
  790.  
  791.  
  792.  
  793.  
  794.  
  795.  
  796. ttttccccllllMMMMoooottttiiiiffff((((3333TTTTmmmm))))                                                    ttttccccllllMMMMoooottttiiiiffff((((3333TTTTmmmm))))
  797.  
  798.  
  799.  
  800.      mainWindow. This holds a menu bar, and a container object such as a form
  801.      or a rowColumn which in turn holds the rest of the application objects.
  802.      So a mainWindow with a list and some buttons in a form would be created
  803.      by
  804.  
  805.           xtAppInitialize -class Example
  806.  
  807.           xmMainWindow .main
  808.           xmForm .main.form
  809.           xmList .main.form.list
  810.           xmPushButton .main.form.btn1
  811.           xmPushButton .main.form.btn2
  812.  
  813.      The form acts as what is called the  ``workWindow''  of  the  mainWindow.
  814.      This resource would be set by
  815.  
  816.           .main setValues -workWindow .main.form
  817.  
  818.      Values would also be set into the list and buttons:
  819.  
  820.           .main.form.list setValues \
  821.                -itemCount 3 \
  822.                -items "one two three" \
  823.                -selectionPolicy single_select
  824.           .main.form.btn1 setValues -labelString Quit
  825.           .main.form.btn2 setValues -labelString "Do nothing"
  826.  
  827.      Behaviour would be set by a callback function
  828.  
  829.           .main.form.btn1 activateCallback {exit 0}
  830.           .main.form.list singleSelectionCallback {puts stdout "Selected %item"}
  831.  
  832.      Geometry would be set for the form, to put the objects in  their  correct
  833.      relation  to  each  other. Suppose this is the list on the left, with the
  834.      two buttons one under the other on the right:
  835.  
  836.           .main.form.list setValues \
  837.                -topAttachment attach_form \
  838.                -leftAttachment attach_form \
  839.                -bottomAttachment attach_form
  840.           .main.form.btn1 setValues \
  841.                -topAttachment attach_form \
  842.                -leftAttachment attach_widget \
  843.                -leftWidget .main.form.list
  844.           .main.form.btn2 setValues \
  845.                -topAttachment attach_widget \
  846.                -topWidget .main.form.btn1 \
  847.                -leftAttachment attach_widget \
  848.                -leftWidget .main.form.list
  849.  
  850.      Finally, windows are created and the main event loop is entered:
  851.  
  852.  
  853.  
  854.  
  855.                                                                        PPPPaaaaggggeeee 11113333
  856.  
  857.  
  858.  
  859.  
  860.  
  861.  
  862. ttttccccllllMMMMoooottttiiiiffff((((3333TTTTmmmm))))                                                    ttttccccllllMMMMoooottttiiiiffff((((3333TTTTmmmm))))
  863.  
  864.  
  865.  
  866.           . realizeWidget
  867.           . mainLoop
  868.  
  869.  
  870. MMMMeeeennnnuuuussss
  871.      Motif supports three types of menus: pulldown menus, popup menus and
  872.      option menus. It does so with a set of basic menu functions and an
  873.      additional set of ``convenience'' functions. tclMotif supports the basic
  874.      functions but not the convenience ones, since each author uses their own
  875.      convenience functions and I am not convinced that the Motif ones are the
  876.      ``best''.
  877.  
  878.      PPPPuuuullllllllddddoooowwwwnnnn mmmmeeeennnnuuuussss
  879.      Pulldown menus need a MenuBar to hold the set of buttons.  These buttons
  880.      must be cascade buttons.  From these are created PulldownMenu widgets,
  881.      which are parented from the MenuBar.  To establish the link between a
  882.      cascade button and its corresponding pulldown menu, the resource
  883.      subMenuId must be set on the cascade buton to be the pulldown menu.  The
  884.      pulldown menu can contain any menu widgets such as push buttons, with
  885.      their associated callbacks.
  886.  
  887.           xmMenuBar .main.menuBar managed
  888.           xmCascadeButton .main.menuBar.file managed \
  889.                   -labelString File \
  890.                   -mnemonic F
  891.           xmCascadeButton .main.menuBar.edit managed \
  892.                   -labelString Edit \
  893.                   -mnemonic E
  894.           xmCascadeButton .main.menuBar.help managed \
  895.                    -labelString Help \
  896.                   -mnemonic H
  897.  
  898.           # file pulldown
  899.           xmPulldownMenu .main.menuBar.fileMenu
  900.           xmPushButton .main.menuBar.fileMenu.new managed \
  901.                   -labelString "New..." \
  902.                   -mnemonic N
  903.           xmPushButton .main.menuBar.fileMenu.quit managed \
  904.                    -labelString Quit \
  905.                   -mnemonic Q
  906.           .main.menuBar.file setValues -subMenuId .main.menuBar.fileMenu
  907.  
  908.      PPPPooooppppuuuupppp mmmmeeeennnnuuuussss
  909.      Popup menus are posted either from  a  keyboard  accelerator  or  from  a
  910.      button  3  press  over  a widget. A popup menu is created by the function
  911.      xmPopupMenu.  A   keyboard   accelerator   is   set   by   the   resource
  912.      menuAccelerator  for  this widget.  A button 3 press is easiest set up by
  913.      adding an action to this button press that calls a menu  popup  function.
  914.      This  function  should  first  call  the  popup  menu  widget  method  of
  915.      menuPosition with one argument: the event that caused  the  popup.   This
  916.      event  can  be  found by the action substitution %event.  After this, the
  917.      popup menu can be managed. Both methods are shown by this example:
  918.  
  919.  
  920.  
  921.                                                                        PPPPaaaaggggeeee 11114444
  922.  
  923.  
  924.  
  925.  
  926.  
  927.  
  928. ttttccccllllMMMMoooottttiiiiffff((((3333TTTTmmmm))))                                                    ttttccccllllMMMMoooottttiiiiffff((((3333TTTTmmmm))))
  929.  
  930.  
  931.  
  932.           proc popIt {event} {
  933.               .fred.menu menuPosition $event
  934.               .fred.menu manageChild
  935.           }
  936.  
  937.           xtAppInitialize -class Program
  938.  
  939.           xmLabel .fred managed -labelString "ctrl-p or Btn3Down popups from me"
  940.           .fred setValues -translations \
  941.                   "<Btn3Down>: action(popIt %event)"
  942.  
  943.           xmPopupMenu .fred.menu -menuAccelerator "Ctrl <Key> p"
  944.           xmPushButton .fred.menu.btn1 managed
  945.           xmPushButton .fred.menu.btn2 managed
  946.  
  947.           . realizeWidget
  948.  
  949.           . mainLoop
  950.  
  951.      OOOOppppttttiiiioooonnnn mmmmeeeennnnuuuussss
  952.      An option menu is made up  of  a  PulldownMenu  that  is  populated  with
  953.      buttons  to give the alternative options. The option label is formed from
  954.      an OptionMenu, with the labelString resource set to  the  label  showing,
  955.      and the subMenuId set to the PulldownMenu.
  956.           # option menu
  957.  
  958.           xtAppInitialize -class Program
  959.  
  960.           xmRowColumn .rc managed
  961.  
  962.           xmPulldownMenu .rc.pulldown1
  963.           xmPushButton .rc.pulldown1.options1 managed \
  964.               -labelString "value 1"
  965.  
  966.           xmPushButton .rc.pulldown1.options2 managed \
  967.               -labelString "value 2"
  968.  
  969.           xmOptionMenu .rc.option1 managed \
  970.               -labelString "Option set" \
  971.               -subMenuId .rc.pulldown1
  972.  
  973.      TTTTeeeeaaaarrrr----ooooffffffff mmmmeeeennnnuuuussss Pulldown and Popup menu panes can be  made  into  tear-off
  974.      menus   by  specifying  the  resource  tearOffModel  to  have  the  value
  975.      tear_off_enabled at the time of  creation.  They  then  show  a  tear-off
  976.      button  as  a dotted line in the menu pane. Clicking on this with BSelect
  977.      tears off the menu in place; dragging on this with  BDrag  will  tear-off
  978.      the menu and drag it elsewhere.
  979.  
  980.      When a menu is a tear-off menu, an  additional  button  is  created  with
  981.      separator-like  behaviour.  This  button  has  a  pathname made up of the
  982.      rowcolumn's name followed by ``.TearOffControl''.  For example,
  983.           xmPulldownMenu .main.menuBar.fileMenu \
  984.  
  985.  
  986.  
  987.                                                                        PPPPaaaaggggeeee 11115555
  988.  
  989.  
  990.  
  991.  
  992.  
  993.  
  994. ttttccccllllMMMMoooottttiiiiffff((((3333TTTTmmmm))))                                                    ttttccccllllMMMMoooottttiiiiffff((((3333TTTTmmmm))))
  995.  
  996.  
  997.  
  998.                   -tearOffModel tear_off_enabled
  999.  
  1000.                   -foreground red -background black
  1001.  
  1002.  
  1003. DDDDrrrraaaagggg aaaannnndddd DDDDrrrroooopppp
  1004.      Drag and drop was introduced into Motif 1.2. It is complicated. We shall
  1005.      first look at the drop side. A widget has to first register itself as a
  1006.      drop site, so that when an attempt is made to drop something on it, it
  1007.      will try to handle it. This registration is done by the widget method
  1008.      ``dropSiteRegister''. This registration must include tcl code to be
  1009.      executed when a drop is attempted, and this is done using the resource
  1010.      ``dropProc''. The first part of what makes D&D hard is that you have
  1011.      potentially two different applications attempting to communicate, one
  1012.      dropping and the other accepting the drop. A protocol is needed between
  1013.      these, so that they share a common language. This is done in registration
  1014.      by saying what types of protocol are used, and how many there are. This
  1015.      is done using X atoms, and the major ones are ``COMPOUND_TEXT'', ``TEXT''
  1016.      and ``STRING''.  Thus registration  by the drop site widget is done, for
  1017.      example, by
  1018.  
  1019.           .l dropSiteRegister \
  1020.                   -dropProc {startDrop %dragContext} \
  1021.                   -numImportTargets 1 \
  1022.                   -importTargets COMPOUND_TEXT
  1023.  
  1024.      This allows `.l' to be used as a drop site,  accepting  ``COMPOUND_TEXT''
  1025.      only.   Multiple  types  are  allowed,  using the Motif list structure of
  1026.      elements separated by commas as in "COMPOUND_TEXT, TEXT, STRING".  When a
  1027.      drop  occurs, the procedure ``startDrop'' is called, with one substituted
  1028.      parameter. This parameter is a ``dragContext'', which is a widget created
  1029.      to  by  Motif  to handle the drag part of all this. You must include this
  1030.      parameter, or the next stage doesn't get  off the ground.
  1031.  
  1032.      When a drag actually occurs, Motif creates a dragContext widget.  A  drag
  1033.      is  started  by holding down the middle button in a drag source, which is
  1034.      discussed later. The dragContext widget contains  information  about  the
  1035.      drag  source,  which  is  to be matched up against where the drop occurs.
  1036.      When the drop occurs, by releasing   the  middle  button,  the  tcl  code
  1037.      registered  as  dropProc  is  executed.  This should have the dragContext
  1038.      widget as parameter.  This code may try to determine if the  drop  should
  1039.      go  ahead,  but  more  normally will just act as a channel through to the
  1040.      actual information transfer.  Still  here?  Good.  The  dragProc  doesn't
  1041.      actually  do  the information transfer, it just determines whether or not
  1042.      it is possible, and if it is, what protocols should be used, and how.
  1043.  
  1044.      The drop receiver may decide that it wants  something  encoded  as  TEXT,
  1045.      followed  by something encoded as COMPOUND_TEXT, and then by something in
  1046.      STRING format (beats me why, though...). it signals this by a (Tcl)  list
  1047.      of dropTransfer pairs, consisting of the protocol (as an X atom name) and
  1048.      the widget that is being dropped on. Huh? Why the widget  that  is  being
  1049.      dropped on? Because when a drop on a widget takes place, this is actually
  1050.  
  1051.  
  1052.  
  1053.                                                                        PPPPaaaaggggeeee 11116666
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060. ttttccccllllMMMMoooottttiiiiffff((((3333TTTTmmmm))))                                                    ttttccccllllMMMMoooottttiiiiffff((((3333TTTTmmmm))))
  1061.  
  1062.  
  1063.  
  1064.      dealt with by the dragContext widget, and  this  is  about  to  hand  the
  1065.      transfer  over to a transferWidget. Yes, I know you are using Tcl because
  1066.      you couldn't handle triple indirections (or rather, don't want to!),  but
  1067.      they occur anyway... So here is a simple dragProc:
  1068.  
  1069.           proc startDrop {dragContext} {
  1070.             $dragContext dropTransferStart \
  1071.                   -dropTransfers {{COMPOUND_TEXT .l}} \
  1072.                   -numDropTransfers 1 \
  1073.                   -transferProc {doTransfer %closure {%value}}
  1074.           }
  1075.  
  1076.      The dragContext widget uses the command dropTransferStart to  signal  the
  1077.      beginning of the information transfer (it could also signal that the drop
  1078.      is to terminate, with no information transfer).  It will accept one chunk
  1079.      of  information  in  the COMPOUND_TEXT format, and pass this on to the .l
  1080.      widget.  The information transfer is  actually  carried  on  by  the  Tcl
  1081.      procedure  in  the  transferProc  resource.  The  only  formats currently
  1082.      accepted (because they are hard-coded into TclMotif)  are  COMPOUND_TEXT,
  1083.      TEXT and STRING.
  1084.  
  1085.      The transferProc resource is a function that  is  called  when  the  drop
  1086.      receiver actually gets the information dropped on it. This should take at
  1087.      least  two  parameters.  The  %value  is  substituted  for   the   actual
  1088.      information  dropped  on  it,  and  %closure is the second element in the
  1089.      dropTransfer list which should be the widget the drop  is  happening  on.
  1090.      (Why  not  let  TclMotif  determine this? I dunno. Consistency with Motif
  1091.      doco? Brain damage late at night?) Then the dropped on  widget  can  take
  1092.      suitable  action.  This  function resets the label to the text dropped on
  1093.      it:
  1094.  
  1095.           proc doTransfer {destination value} {
  1096.             $destination setValues -labelString $value
  1097.           }
  1098.  
  1099.      where destination is substituted by %closure and value by %value.
  1100.  
  1101.      So much for the drop site, receiving widget. On the other side, a  widget
  1102.      has to prepared to act as a drag source and then to send information when
  1103.      dropped.
  1104.  
  1105.      A drag action is commenced  (according  to  the  Motif  Style  Guide)  by
  1106.      dragging Button Two in the widget. To get this behaviour, the translation
  1107.      table for the widget has to  have  the  Button2  action  overriden.   For
  1108.      example,
  1109.  
  1110.           xmScrollBar .sb managed \
  1111.             -translations "#override <Btn2Down>: action(startDrag %w)"
  1112.  
  1113.      This will call the application defined ``startDrag''  function  with  the
  1114.      widget  as argument. The purpose of this function is to call the ``drag''
  1115.      method for that widget:
  1116.  
  1117.  
  1118.  
  1119.                                                                        PPPPaaaaggggeeee 11117777
  1120.  
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126. ttttccccllllMMMMoooottttiiiiffff((((3333TTTTmmmm))))                                                    ttttccccllllMMMMoooottttiiiiffff((((3333TTTTmmmm))))
  1127.  
  1128.  
  1129.  
  1130.           proc startDrag {w} {
  1131.             $w dragStart \
  1132.               -exportTargets COMPOUND_TEXT \
  1133.               -numExportTargets 1 \
  1134.               -convertProc {dragConvertProc %w %type %value}
  1135.           }
  1136.  
  1137.      This states  that  it  is  only  prepared  to  send  a  message  of  type
  1138.      ``COMPOUND_TEXT'',   and  when  the toolkit requires the dropped value it
  1139.      will call the application defined function ``dragConvertProc'' with three
  1140.      parameters:  the widget, the data-type that is to be transferred, and the
  1141.      data value to  be  transferred.  These  last  two  are  modified  by  the
  1142.      function,  so  are actually variables in the parent's context. These have
  1143.      to be modified using upvar.
  1144.  
  1145.      For example, to send the value of a slider widget as  COMPOUND_TEXT,  the
  1146.      ``dragConvertProc'' would be:
  1147.  
  1148.           proc dragConvertProc {w type value} {
  1149.             upvar 1 $type t
  1150.             upvar 1 $value v
  1151.  
  1152.             $w getValues -value v
  1153.             set t COMPOUND_TEXT
  1154.           }
  1155.  
  1156.      tclMotif has builtin  support  for  drops  of  three  data  types:  TEXT,
  1157.      COMPOUND_TEXT  and  STRING. These form a large majority of the data types
  1158.      that may be dropped onto a widget. However,  there  may  be  others.   To
  1159.      allow  for  this,  tclMotif has a procedure Tm_InstallDropType that takes
  1160.      three parameters: a tcl interpreter, a string that will  be  used  as  an
  1161.      Atom to label a datatype, and a function of type
  1162.           char *(*) ()
  1163.      When a function is registered by using this command, it must  be  capable
  1164.      of  transforming the datatype into a string, which it returns as value of
  1165.      the function. If this method is used, it should be added  using  the  tcl
  1166.      extension techniques.
  1167.  
  1168.  
  1169. SSSSeeeennnndddd
  1170.      Tk has a primitive called ``send''. In this, each interpreter has a name,
  1171.      and you can send tcl commands from one interpreter to another. When an
  1172.      interpreter receives a sent command it executes it, and returns any
  1173.      result back to the original interpreter. This mechanism is also available
  1174.      to TclMotif, so that Motif applications can set commands to other Motif
  1175.      applications, and also to and from Tk ones.
  1176.  
  1177.      If a TclMotif application succeeds in registering its name, from then on,
  1178.      it can send to another. For example,
  1179.  
  1180.           send interp2 {puts stdout "hello there"}
  1181.  
  1182.  
  1183.  
  1184.  
  1185.                                                                        PPPPaaaaggggeeee 11118888
  1186.  
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192. ttttccccllllMMMMoooottttiiiiffff((((3333TTTTmmmm))))                                                    ttttccccllllMMMMoooottttiiiiffff((((3333TTTTmmmm))))
  1193.  
  1194.  
  1195.  
  1196.      instructs ``interp2'' to display a message.
  1197.  
  1198.      Similarly,  once  the  ``send''  command  has   been   registered,   this
  1199.      application can be sent commands from other applications. The name of the
  1200.      interpreter is the ```title''  resource  of  the  top-level  widget  `.'.
  1201.      Generally  this  will  be  the  same  as the application name, but may be
  1202.      changed in two ways:  first the ``title''  resource  may  have  been  set
  1203.      explicitly.   Secondly,   ``send''   requires   a  unique  name  for  the
  1204.      interpreter, so if an application is already running with that  title,  a
  1205.      ``#2'',  or  ``#3'', etc will be apended to the title until it is unique.
  1206.      This is not really satisfactory, but is the way that Tk does it.
  1207.  
  1208.  
  1209. XXXXlllliiiibbbb DDDDrrrraaaawwwwiiiinnnngggg
  1210.      Motif only uses two widgets for Xlib style drawing: the DrawnButton and
  1211.      the DrawingArea. tclMotif allows drawing into these widgets, and does not
  1212.      allow drawing into other types of widget.
  1213.  
  1214.      At present, the drawing functions are limited to XDrawImageString, using
  1215.      the method ``drawImageString''. This requires use of a graphics context.
  1216.      A graphics context is first obtained by the call
  1217.           $w getGC -foreground fg -background
  1218.      Any widget can be used for this, but typically the drawing widget will be
  1219.      used.
  1220.  
  1221.      Given a graphics context, text can be drawn by
  1222.           $w drawImageString gc x y text
  1223.  
  1224.  
  1225. MMMMooooddddaaaallll ddddiiiiaaaallllooooggggssss
  1226.      Dialogs in Motif are modeless by default. A dialog can be made modal by
  1227.      using the BulletinBoard resource dialogStyle which can be set to values
  1228.      such as ``dialog_full_application_modal''. This makes the dialog modal
  1229.      for the application, so that the dialog has to be completed before any
  1230.      interaction can occur with the rest of the application. Here
  1231.      ``completed'' means that the dialog must be unmanaged or destroyed.
  1232.  
  1233.      There is a serious difficulty in making dialogs modal: the modality is
  1234.      enforced by Xt, so that control must pass to Xt so that it can make the
  1235.      dialog modal. This usually means that no application code can follow
  1236.      setting the dialog resource, because control must pass back to the Xt
  1237.      event main loop.
  1238.  
  1239.      The problem here is that this is often what the programmer explicitly
  1240.      does _n_o_t want to do. A typical piece of code using modality is to ask a
  1241.      question such as ``remove file'' and use a modal dialog to wait for the
  1242.      answer and use it to determine what to do next. To allow this type of
  1243.      use, the application has to use its own event loop, and this is done by
  1244.      the `root' widget command ``processEvent'' which handles one event at a
  1245.      time.
  1246.  
  1247.      A modal piece of code sets up a loop around the ``processEvent'' method.
  1248.  
  1249.  
  1250.  
  1251.                                                                        PPPPaaaaggggeeee 11119999
  1252.  
  1253.  
  1254.  
  1255.  
  1256.  
  1257.  
  1258. ttttccccllllMMMMoooottttiiiiffff((((3333TTTTmmmm))))                                                    ttttccccllllMMMMoooottttiiiiffff((((3333TTTTmmmm))))
  1259.  
  1260.  
  1261.  
  1262.      This loop is controlled by a Boolean flag which is initially true.  When
  1263.      the flag is set to false the loop terminates. The loop is typically set
  1264.      to false by pressing the various buttons in the dialog.  For example
  1265.  
  1266.           proc ask {parent question} {
  1267.               global stillModal
  1268.               global answer
  1269.  
  1270.               xmQuestionDialog $parent.dialog managed \
  1271.                -messageString $question \
  1272.                -dialogStyle dialog_full_application_modal
  1273.  
  1274.               $parent.dialog okCallback {set stillModal 0; set answer 1}
  1275.               $parent.dialog cancelCallback {set stillModal 0; set answer 0}
  1276.  
  1277.               set stillModal 1
  1278.               while {$stillModal} {
  1279.                . processEvent
  1280.               }
  1281.               $parent.dialog destroyWidget
  1282.           }
  1283.  
  1284.      This can then be used in normal sequential code
  1285.  
  1286.           if {ask $w "remove $file"} {
  1287.               exec rm $file
  1288.           }
  1289.  
  1290.  
  1291. AAAAddddddddiiiittttiiiioooonnnnaaaallll ttttoooopppplllleeeevvvveeeellll sssshhhheeeellllllllssss
  1292.      Additional toplevel shells may be created using the command
  1293.      topLevelShell.  This shell may use any widget for its parent.  In order
  1294.      to make this shell visible, it must be popped up.
  1295.           xtAppInitialize
  1296.           xmLabel .label managed \
  1297.               -labelString "label in app shell"
  1298.           topLevelShell .toplevel
  1299.           xmLabel .toplevel.label managed \
  1300.               -labelString "label in toplevel"
  1301.  
  1302.      Do _n_o_t atttempt to manage the toplevel shell - this will place  it  under
  1303.      the  geometry  control  of its parent, so that when the parent resizes so
  1304.      will the shell! While this can produce some visually  intriguing  effects
  1305.      it is probably not what is desired, as well as breaking Xt rules.
  1306.  
  1307.  
  1308. EEEExxxxtttteeeennnnddddiiiinnnngggg mmmmooooaaaatttt
  1309.      From Tcl 7.0 onwards, a standard method was set up to allow extensions to
  1310.      be made in a consistent manner. tclMotif follows this extension method.
  1311.      The method allows for open-ended extensions so that further extensions
  1312.      can be made to moat. You need access to the tcl library and also to the
  1313.      tclMotif library.
  1314.  
  1315.  
  1316.  
  1317.                                                                        PPPPaaaaggggeeee 22220000
  1318.  
  1319.  
  1320.  
  1321.  
  1322.  
  1323.  
  1324. ttttccccllllMMMMoooottttiiiiffff((((3333TTTTmmmm))))                                                    ttttccccllllMMMMoooottttiiiiffff((((3333TTTTmmmm))))
  1325.  
  1326.  
  1327.  
  1328.      Tcl expects a C function Tcl_AppInit() to be defined. This function
  1329.      should contain initialisation statements for each extension. In the case
  1330.      of tclMotif this function must contain a call to
  1331.           Tm_AppInit(interp)
  1332.      The prototype for this function is in tm.h, so this should be included as
  1333.      well.
  1334.  
  1335.      To perform your own extension,  write  your  own  Tcl_AppInit()  function
  1336.      based  on  any  existing ones as a template, including the above line and
  1337.      any similar code for the other extensions. Then  compile  and  link  this
  1338.      with the tcl and extension libraries.
  1339.  
  1340.      To add in additional widgets, see a later section for an easier way to do
  1341.      this.
  1342.  
  1343.  
  1344. KKKKeeeeyyyybbbbooooaaaarrrrdddd ttttrrrraaaavvvveeeerrrrssssaaaallll
  1345.      Keyboard traversal is normally handled automatically by Motif.  Sometimes
  1346.      it is necessary for the application to reset the keyboard focus to a
  1347.      particular widget or to the ``next'' widget in a set.  The widgets are
  1348.      grouped in sets called ``tab groups'' by Motif.  Tab group manipulation
  1349.      has not been added to tclMotif (at version 1.0).
  1350.  
  1351.      Keyboard focus may be set using the method ``processTraversal'' which
  1352.      takes a single argument. This may take values such as ``next'', ``up'',
  1353.      ``right'' to move to a suitable widget.
  1354.  
  1355.  
  1356. AAAApppppppplllliiiiccccaaaattttiiiioooonnnn iiiiccccoooonnnnssss
  1357.      Toplevel widgets such as the application widget can have an icon attached
  1358.      to them so that it is shown when the application is iconified.  This is
  1359.      done using the resource iconPixmap for the toplevel widget.  The value of
  1360.      the resource is a filename containing the pixmap definition.  This file
  1361.      may be found in a large set of directories such as the current directory
  1362.      or /usr/lib/X11/bitmaps. The full set - and the environment variables
  1363.      that control this set - is documented in the Motif call XmGetPixmap().
  1364.  
  1365.  
  1366. AAAAuuuuttttoooommmmaaaatttteeeedddd tttteeeessssttttiiiinnnngggg
  1367.      Tcl uses an automated test system that can run regression tests on a
  1368.      system.  it does so by ``sourcing'' a file containing a set of test
  1369.      procedures, including a procedure called ``test''. This takes 4
  1370.      arguments: the first is the name of the test, the second is a textual
  1371.      description of the test, the third is the code to execute to perform the
  1372.      test, and the last is the expected result. The ``test'' procedure runs
  1373.      the test and if the actual result differs from the expected one, an error
  1374.      message is printed.
  1375.  
  1376.      This mechanism is used well for the tcl core. It is also used for Tk, but
  1377.      with less success: while good for batch mode testing, it does not handle
  1378.      the interactive nature of GUI environments. To perform batch mode testing
  1379.      in such environments, one needs to be able to create input events to
  1380.  
  1381.  
  1382.  
  1383.                                                                        PPPPaaaaggggeeee 22221111
  1384.  
  1385.  
  1386.  
  1387.  
  1388.  
  1389.  
  1390. ttttccccllllMMMMoooottttiiiiffff((((3333TTTTmmmm))))                                                    ttttccccllllMMMMoooottttiiiiffff((((3333TTTTmmmm))))
  1391.  
  1392.  
  1393.  
  1394.      simulate an interactive user.
  1395.  
  1396.      One approach is to create raw X events and to feed them directly into the
  1397.      Xt event loop handler. This requires a very low-level knowledge of what
  1398.      is going on, and anyway does not reflect the object structure of the Xt
  1399.      toolkit. Each widget defines a set of ``actions'' that are intended to be
  1400.      the ``public'' interface of that widget. This is the hook that the
  1401.      tclMotif test procedures use to extend the tcl testing into this GUI
  1402.      environment.
  1403.  
  1404.      A command for any widget is ``callActionProc''. This takes an argument
  1405.      which is the name of the action for the widget. For example, a button has
  1406.      an Arm action, so this can be invoked by
  1407.  
  1408.           .btn callActionProc Arm()
  1409.  
  1410.      This will perform the visual behaviour for this action, and also call any
  1411.      callbacks associated with this action.
  1412.  
  1413.      This sends (by default) a ClientMessage event to the widget. Most widgets
  1414.      ignore  the  event,  so  this  is sufficient.  Some actions require event
  1415.      detail, though. For example, when a  mouse  button  release  occurs,  the
  1416.      widget  checks  to  see  if  the  release  occurred _i_n_s_i_d_e or _o_u_t_s_i_d_e the
  1417.      widget. It does this  because  if  the  event  occurs  inside,  then  the
  1418.      callbacks  attached  to  the Activate() action are invoked, but otherwise
  1419.      they  are  not.   To  handle  this,  an  event   of   type   ButtonPress,
  1420.      ButtonRelease,  KeyPress  or  KeyRelease can be prepared with some fields
  1421.      set.
  1422.  
  1423.      For tests, this means that you cannot just issue an Activate action.  You
  1424.      do have to prepare an X button event to the extent of setting the x and y
  1425.      coordinates so that the internal Motif function can determine whether  or
  1426.      not to invoke the callbacks. This looks like:
  1427.  
  1428.           .btn callActionProc Activate \
  1429.               -type ButtonPress \
  1430.               -x 0 -y 0
  1431.  
  1432.      to be within the widget, or
  1433.  
  1434.           .btn getValues -width w -height h
  1435.           set big_h [expr {2 * $h}]
  1436.           set big_w [expr {2 * $w}]
  1437.           .btn callActionProc Activate \
  1438.               -type ButtonPress \
  1439.               -x $big_w -y $big_h
  1440.  
  1441.      to be outside the widget.
  1442.  
  1443.  
  1444.      Some of the Text manipulation actions require a KeyPress event,  such  as
  1445.      ``self-insert()'',  which inserts the character pressed. The character is
  1446.  
  1447.  
  1448.  
  1449.                                                                        PPPPaaaaggggeeee 22222222
  1450.  
  1451.  
  1452.  
  1453.  
  1454.  
  1455.  
  1456. ttttccccllllMMMMoooottttiiiiffff((((3333TTTTmmmm))))                                                    ttttccccllllMMMMoooottttiiiiffff((((3333TTTTmmmm))))
  1457.  
  1458.  
  1459.  
  1460.      actually encoded as a keycode, which is a hardware  dependant  code,  too
  1461.      low-level  for  this binding. To prepare such an event, this toolkit uses
  1462.      _k_e_y_s_y_m_s  which  are  abstractions  for  each  type  of  key  symbol.  The
  1463.      alphanumerics  have  simple representations as themselves (`a', `A', `2',
  1464.      etc). Others have symbolic  names  (`space',  `Tab',  `BackSpace',  etc).
  1465.      These   are   derived  from  the  X  Reference  manual  or  in  the  file
  1466.      <X11/keysymdefs.h> by removing the prefix ``XK_''.
  1467.  
  1468.      For example, to insert the three characters `A a' into .text
  1469.  
  1470.           .text callActionProc self-insert() \
  1471.                   -type KeyPress \
  1472.                   -keysym A
  1473.           .text callActionProc self-insert() \
  1474.                   -type KeyPress \
  1475.                   -keysym space
  1476.           .text callActionProc self-insert() \
  1477.                   -type KeyPress \
  1478.                   -keysym a
  1479.  
  1480.      The set of actions that require this level of preparation of the X  event
  1481.      is  nowhere  documented explicitly. You have to read between the lines of
  1482.      the Motif documentation, or guess at  behaviour  (or  read  Motif  source
  1483.      code).
  1484.  
  1485.  
  1486. AAAAddddddddiiiinnnngggg wwwwiiiiddddggggeeeettttssss
  1487.      [All the methods described in this section are new and a bit
  1488.      experimental.  If there are any problems, please let me know.]
  1489.  
  1490.      tclMotif has support for the widget set supplied in the Motif toolkit.
  1491.      There are an increasing number of Motif-compatable widgets becoming
  1492.      available from third party sources. To add any of these involves adding
  1493.      appropriate C code to tclMotif.
  1494.  
  1495.      The file tmExtern.c contains some data structures that would have to be
  1496.      changed, and some skeleton code to assist in more complex tasks.  You
  1497.      should make a copy of this file and either use it to replace the supplied
  1498.      tmExtern.c in each future release of tclMotif, or ensure that your
  1499.      version of this file is linked into each application before the supplied
  1500.      one.
  1501.  
  1502.      The array Tm_ExternCommands can be used to add additional commands to
  1503.      tclMotif. It is an array of type Tm_Cmd, which is a structure The
  1504.      elements of this structure are
  1505.           The string that is the widget creation name
  1506.           The  C function that is used to actually create the widget
  1507.           The C function that is used to process the commands/methods issued
  1508.           to the new widget
  1509.      If there is nothing special about creating this widget, make the second
  1510.      element of this array Tm_AnyCmd.  If the widget has no special methods of
  1511.      its own, make the third element of this array Tm_AnyWidgetCmd.
  1512.  
  1513.  
  1514.  
  1515.                                                                        PPPPaaaaggggeeee 22223333
  1516.  
  1517.  
  1518.  
  1519.  
  1520.  
  1521.  
  1522. ttttccccllllMMMMoooottttiiiiffff((((3333TTTTmmmm))))                                                    ttttccccllllMMMMoooottttiiiiffff((((3333TTTTmmmm))))
  1523.  
  1524.  
  1525.  
  1526.      For example,
  1527.           Tm_Cmd Tm_ExternCommands[] = {
  1528.               {"htmlWidget",     Tm_AnyCmd,        Tm_AnyWidgetCmd},
  1529.               {"myWidget",       MyCreateCmd,      MyWidgetCmd},
  1530.               {(char *) NULL,    (int (*)()) NULL, (Tm_WidgetCmdProc) NULL}
  1531.           };
  1532.      adds in two more commands, ``htmlWidget''  and  ``myWidget'',  where  the
  1533.      htmlWidget has no special creation requirements and no additional methods
  1534.      to the Core widget. On the other hand, myWidget has both special  purpose
  1535.      creation  requirements  and  additional methods, so needs custom creation
  1536.      and method functions. A skeleton for these two functions is  supplied  in
  1537.      the file tmExtern.c
  1538.  
  1539.      In addition the array Tm_ExternCommandToClass contains a mapping from the
  1540.      tcl  widget  creation  command to the Xt class. This is used by Tm_AnyCmd
  1541.      and also by the String to WidgetClass converter. The first entry in  this
  1542.      is  the  widget creation string, and the second entry is a _p_o_i_n_t_e_r to the
  1543.      Xt class. For example,
  1544.           Tm_CommandToClassType Tm_ExternCommandToClass[] = {
  1545.  
  1546.               /*
  1547.                * Example: the Mosaic html widget:
  1548.                */
  1549.                   {"htmlWidget", &htmlWidgetClass},
  1550.  
  1551.               /*
  1552.                * array terminator - do not remove or
  1553.                * place anything after this
  1554.                */
  1555.               {NULL, NULL}
  1556.           };
  1557.  
  1558.      Additional widgets will have their own callbacks, and will probably  have
  1559.      a callback structure associated to each. To allow `%' substitutions to be
  1560.      used   in   callback   code   for    these    widgets,    the    function
  1561.      Tm_ExternExpandPercent  (in  tmExtern.c)  may  be modified to add in such
  1562.      substitutions.
  1563.  
  1564.      You will finally need to make a  change  to  the  Imakefile  in  the  src
  1565.      directory, by setting the variables EXTRA_WIDGETS_INCLUDE to point to the
  1566.      include directory and EXTRA_WIDGETS_LIB to link in the library containing
  1567.      these extra widgets. For example,
  1568.           EXTRA_WIDGETS_INCLUDE = /usr/local/include/html
  1569.           EXTRA_WIDGETS_LIB = -lhtmlw
  1570.  
  1571.      this may be simplified by using the command ``addwidget''. This takes the
  1572.      name  of a widget and looks in the directory ``extern_widgets'' for a set
  1573.      of description files. For a widget ``foo'', these are:
  1574.  
  1575.            _f_o_o this contains lines specifying  a  pattern  and  a  value.  The
  1576.           patterns are
  1577.                command
  1578.  
  1579.  
  1580.  
  1581.                                                                        PPPPaaaaggggeeee 22224444
  1582.  
  1583.  
  1584.  
  1585.  
  1586.  
  1587.  
  1588. ttttccccllllMMMMoooottttiiiiffff((((3333TTTTmmmm))))                                                    ttttccccllllMMMMoooottttiiiiffff((((3333TTTTmmmm))))
  1589.  
  1590.  
  1591.  
  1592.                class
  1593.                create-function
  1594.                method-function
  1595.                include-file
  1596.                reason
  1597.                library
  1598.                include-dir
  1599.           The command is the tcl command to create the widget,  the  class  is
  1600.           the  Xt class of the widget, the create-function is the C command to
  1601.           create the widget, the method-function is the C  command  to  handle
  1602.           methods,  the include-file's are the any extra includes that need to
  1603.           be added to tmExtern.c, the reason's are any additional reasons that
  1604.           may  be  available  for your widget, the library is the link library
  1605.           for the widgets, and the include-dir is any additional path for  the
  1606.           compiler to locate include files.
  1607.  
  1608.            _f_o_o._i_n_i_t_i_a_l_i_s_e This contains the  code  to  be  inserted  into  the
  1609.           function  Tm_ExternWidgetsInitialise.  If  this file does not exist,
  1610.           then no code will be inserted.
  1611.  
  1612.            _f_o_o._e_x_p_a_n_d This contains the code to be inserted into the  function
  1613.           Tm_ExternExpandPercent.  If  this  file does not exist, then no code
  1614.           will be inserted.
  1615.  
  1616.            _f_o_o._c_o_m_m_a_n_d_s This contains the function definitions  for  any  non-
  1617.           standard  widget creation and method handling that the extra widgets
  1618.           require.
  1619.  
  1620.      [If you make a description file for a widget, please send it  to  me  for
  1621.      inclusion in the next release.]
  1622.  
  1623.  
  1624. PPPPaaaatttttttteeeerrrrnnnnssss ffffoooorrrr ccccoooommmmmmmmaaaannnnddddssss
  1625.      Pathnames for commands can become very long for complex widget
  1626.      hierarchies. The ``unknown'' command has been augmented for tclMotif to
  1627.      allow patterns to be used as abbreviations for commands. The patterns are
  1628.      those accepted by the tcl command ``info''.  The way that it is expected
  1629.      that this will be used in tclMotif is that a long path will be
  1630.      abbreviated by replacing an initial portion of the command by ``*'' or
  1631.      ``.*'' as in
  1632.      by
  1633.      (It is recommended that the `.' be used to start patterns in  order  that
  1634.      widgets  are  selected  rather  than  other tcl commands.)  Note that the
  1635.      pattern must uniquely match a command/widget name for the  pattern  match
  1636.      to be successful.
  1637.  
  1638.      The ``unknown'' procedure is  augmented  in  the  file  init_tclMotif.tcl
  1639.      which  is  installed  in  the  default  X11  library directory (typically
  1640.      /usr/lib/X11).  This  is  loaded  by  the  tclMotif  library  unless  the
  1641.      environment  variable  TM_LIBRARY  is  set to another directory, in which
  1642.      case the file init_tclMotif.tcl in that directory will be loaded instead.
  1643.  
  1644.  
  1645.  
  1646.  
  1647.                                                                        PPPPaaaaggggeeee 22225555
  1648.  
  1649.  
  1650.  
  1651.  
  1652.  
  1653.  
  1654. ttttccccllllMMMMoooottttiiiiffff((((3333TTTTmmmm))))                                                    ttttccccllllMMMMoooottttiiiiffff((((3333TTTTmmmm))))
  1655.  
  1656.  
  1657.  
  1658.      Any tcl program can rename any procedure, in particular  the  ``unknown''
  1659.      procedure.  If  this  is  done,  then this pattern matching will cease to
  1660.      work. If you wish to prepend your own ``unknown'' procedure to  this,  it
  1661.      is   recommended   that  you  follow  the  ``stack''  structure  used  in
  1662.      init_tclMotif.tcl.
  1663.  
  1664.  
  1665. UUUUIIIILLLL
  1666.      UIL (User Interface Language) is a declarative language for describing
  1667.      the widgets that make up an application. There is little to be gained by
  1668.      programming in UIL over programming in tclMotif. However, many interface
  1669.      builders have the option of outputting UIL code, and this can be used by
  1670.      tclMotif.
  1671.  
  1672.      A UIl file is translated into a UID file by the uil compiler. This can be
  1673.      loaded by
  1674.      The hierarchy can be closed by
  1675.      Only one hierarchy can be opened per program.
  1676.  
  1677.      A UIL widget tree can be attached to any widget by
  1678.           $w mrmFetchWidget uil-widget
  1679.  
  1680.      A traversal is made of the  UIL  widget  tree,  adding  information  that
  1681.      allows  them to be used as tclMotif Core widgets. This means that you can
  1682.      use methods such as getValues, setValues, etc. Note that the top  of  the
  1683.      UIL  tree  is  created unmanaged, so that you will will need to manage it
  1684.      yourself. For example:
  1685.               -topAttachment attach_form
  1686.  
  1687.      Callbacks in the UIL file should always be to the procedure ``tcl'' which
  1688.      takes  a  single  string argument. This argument is the tcl command to be
  1689.      executed. For example, the UIL for an activateCallback may be
  1690.           XmNactivateCallback = procedure tcl("puts stdout goodbye");
  1691.      Widget names may be used in the callback procedures, but at present no  %
  1692.      substitutions  are supported (if you need them, let me know).  Due to the
  1693.      impossibility of knowing exactly what the widget hierarchy will  be  when
  1694.      the UIL file is used, it is suggested that patterns described in the last
  1695.      section be used for widget names, as in
  1696.           XmNactivateCallback = procedure
  1697.                 tcl("*btn setValues -labelString pushed");
  1698.  
  1699.  
  1700. AAAAuuuutttthhhhoooorrrr
  1701.      Jan Newmarch, University of Canberra, PO Box 1, Belconnen, ACT 2616,
  1702.      Australia. Email: jan@ise.canberra.edu.au.
  1703.  
  1704.  
  1705.  
  1706.  
  1707.  
  1708.  
  1709.  
  1710.  
  1711.  
  1712.  
  1713.                                                                        PPPPaaaaggggeeee 22226666
  1714.  
  1715.  
  1716.  
  1717.